//
//  MSVerticalCenterButton.m
//  MSCustomTabBarController
//
//  Created by MrSong on 16/6/4.
//  Copyright © 2016年 MrSong. All rights reserved.
//

#import "MSVerticalCenterButton.h"

@implementation MSVerticalCenterButton
// button上的图片和文字垂直排列，水平居中
-(void)layoutSubviews {
    [super layoutSubviews];
    CGRect rect;
    rect = self.bounds;
    CGSize size;
    size = self.imageView.bounds.size;
    CGSize fontSize;
    fontSize = [self.titleLabel.text sizeWithAttributes:@{NSFontAttributeName:self.titleLabel.font}];
    self.imageView.frame=CGRectMake((rect.size.width - size.width)/2, (rect.size.height-size.height-5-fontSize.height)/2+3, size.width, size.height);
    self.titleLabel.frame=CGRectMake((rect.size.width - fontSize.width)/2, (rect.size.height-size.height-5-fontSize.height)/2+size.height+8, fontSize.width, fontSize.height);
}

@end
